package com.ckd.flyingtrip.utils;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.androidkun.PullToRefreshRecyclerView;
import com.androidkun.callback.PullToRefreshListener;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.bumptech.glide.Glide;
import com.ckd.flyingtrip.R;
import com.ckd.flyingtrip.activity.UserLogInActivity;
import com.ckd.flyingtrip.constants.App;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;

/**
 * Created by HITMAN on 2018/6/27.
 */
public class Tools {

    public static Intent intent;
    /*
     * 判断是否有值 是空返回false  非空返回true
     * */


    public static boolean isEmpeyNull(String str) {
        return !(str == null || str.length() == 0 || str.equals("") || str.equals("null") || str.equals(null));
    }

    /*
     * 多字符串驗證非空
     * */
    public static boolean isEmpeyNull(String... str) {
        if (str.length > 0) {
            for (String aStr : str) {
                if (!isEmpeyNull(aStr)) {
                    return false;
                }
            }
        } else {
            return false;
        }
        return true;
    }

    public static boolean isEmpeyNull(Object str) {
        return !(str == null || str.equals("") || str.equals("null") || str.equals(null));
    }

    public static boolean isEmpeyNull(int str) {
        return !(str == 0);
    }

    public static boolean isEmpeyNull(double str) {
        return !(str == 0.0);
    }

    public static boolean isEmpeyNull(List list) {
        return !(list == null || list.equals(null) || list.size() == 0);
    }

    public static boolean isEmpeyNull(Map map) {
        return !(map == null || map.equals(null) || map.size() == 0);
    }

    /*
     * ==================================================================================================================================
     * */
    public static void callPhone(Context mContext, String num) {
        try {
            TelephonyManager telMgr = (TelephonyManager) mContext
                    .getSystemService(Context.TELEPHONY_SERVICE);
            int simState = telMgr.getSimState();
            int absent = TelephonyManager.SIM_STATE_ABSENT;
            if (simState == absent) {
                toast("请确认SIM卡是否插入或者SIM卡暂时不可用！");
                return;
            }
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
                    + num.trim()));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
        } catch (Exception e) {
            new AlertDialog.Builder(mContext)
                    .setTitle("温馨提示")
                    .setMessage("当前设备不支持电话拨打，请用可拨号的设备拨打：" + num)
                    .setPositiveButton("确定",
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog,
                                                    int which) {
                                    dialog.dismiss();
                                }
                            }).create().show();

            e.printStackTrace();
        }
    }

    // 两次点击按钮之间的点击间隔不能少于1000毫秒
    private static final int MIN_CLICK_DELAY_TIME = 1000;
    private static long lastClickTime;

    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }

    /*
     * 提示
     * */
    public static void toast(String str) {
        Toast.makeText(App.getContext(), str, Toast.LENGTH_SHORT).show();
    }

    /**
     * 清除缓存
     */
    public static void clearAllCache(Context context) {
        deleteDir(context.getCacheDir());
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            deleteDir(context.getExternalCacheDir());
        }
    }

    private static boolean deleteDir(File dir) {
        if (dir != null && dir.isDirectory()) {
            String[] children = dir.list();
            if (children != null) {
                for (String aChildren : children) {
                    boolean success = deleteDir(new File(dir, aChildren));
                    if (!success) {
                        return false;
                    }
                }
            }
        }
        assert dir != null;
        return dir.delete();
    }

    /**
     * 获取缓存大小
     *
     * @param context
     * @return
     * @throws
     */
    public static String getTotalCacheSize(Context context) throws Exception {
        long cacheSize = getFolderSize(context.getCacheDir());
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            cacheSize += getFolderSize(context.getExternalCacheDir());
        }
        return getFormatSize(cacheSize);
    }

    public static long getFolderSize(File file) throws Exception {
        long size = 0;
        try {
            File[] fileList = file.listFiles();

            for (int i = 0; i < fileList.length; i++) {
                // 如果下面还有文件
                if (fileList[i].isDirectory()) {
                    size = size + getFolderSize(fileList[i]);
                } else {
                    size = size + fileList[i].length();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return size;
    }

    public static String getFormatSize(double size) {
        double kiloByte = size / 1024;
        if (kiloByte < 1) {
//            return size + "Byte";
            return "0K";
        }

        double megaByte = kiloByte / 1024;
        if (megaByte < 1) {
            BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
            return result1.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "K";
        }

        double gigaByte = megaByte / 1024;
        if (gigaByte < 1) {
            BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
            return result2.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "M";
        }

        double teraBytes = gigaByte / 1024;
        if (teraBytes < 1) {
            BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
            return result3.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "GB";
        }
        BigDecimal result4 = new BigDecimal(teraBytes);
        return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()
                + "TB";
    }
    /*
     * ==================================================================================================================================
     * */


    //普通跳转
    public static void startIntent(Activity activity, Class classname) {
        intent = new Intent(activity, classname);
        activity.startActivity(intent);
    }

    //分红维护跳转
    public static void startIntentFINISH(Activity activity, Class classname) {
        intent = new Intent(activity, classname);
        activity.startActivity(intent);
        activity.setResult(Activity.RESULT_OK);
        activity.finish();
    }

    //普通跳转
    public static void startIntentanimation(Activity activity, Class classname) {
        intent = new Intent(activity, classname);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
    }

    //清盏跳转
    public static void startIntent(Activity context, Class classname, boolean b) {
        if (b) {
            Intent intent = new Intent(context, classname).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
            context.overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
            context.finish();
        }
    }

    /*
     * 顶部
     * */

    public static void title_info(final Activity context, String name) {
        TextView title_name = (TextView) context.findViewById(R.id.cd_title_btn);
        title_name.setText(name);
        context.findViewById(R.id.cd_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.setResult(Activity.RESULT_OK);
                context.finish();
            }
        });
    }
    /*
     * 顶部 注册 忘记密码
     * */

    public static void title_info(final Activity context, String name, String title) {
        TextView title_name = (TextView) context.findViewById(R.id.cd_title_btn);
        title_name.setText(name);
        TextView cd_title_bu = (TextView) context.findViewById(R.id.cd_title_bu);
        cd_title_bu.setText(title);
        context.findViewById(R.id.cd_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.setResult(Activity.RESULT_OK);
                context.finish();
            }
        });
    }
    /*
     * 顶部不带返回
     * */

    public static void title_info(final Activity context, String name, boolean b) {
        if (b) {
            TextView title_name = (TextView) context.findViewById(R.id.cd_title_btn);
            title_name.setText(name);
            ImageView viewById = context.findViewById(R.id.cd_title_img);
            viewById.setVisibility(View.GONE);

        }
    }


//
//    private static void showWindow(View v, final Activity activity) {
//            View view = null;
//        //设置弹出框
//        view= LayoutInflater.from(activity).inflate(R.layout.popwindow_item_view,null);
//        final PopupWindow popupWindow=new PopupWindow();
//        popupWindow.setContentView(view);//设置要弹出的界面
//        // 产生背景变暗效果
//        WindowManager.LayoutParams lp = activity.getWindow()
//                .getAttributes();
//        lp.alpha = 0.6f;
//        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//        activity.getWindow().setAttributes(lp);
//        popupWindow.setWidth(DrawerLayout.LayoutParams.WRAP_CONTENT);//设置弹出框的尺寸为适应控件
//        popupWindow.setHeight(DrawerLayout.LayoutParams.WRAP_CONTENT);
//        popupWindow.setFocusable(true);
//        popupWindow.setTouchable(true);
//        int[] location = new int[2];
//        view.getLocationOnScreen(location);
//        popupWindow.showAsDropDown(v);
//        popupWindow.update();
//        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
//            // 在dismiss中恢复透明度
//            public void onDismiss() {
//                WindowManager.LayoutParams lp = activity.getWindow()
//                        .getAttributes();
//                lp.alpha = 1f;
//                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//                activity.getWindow().setAttributes(lp);
//            }
//        });
//
//        /*
//        * 修改密码
//        * */
//        view.findViewById(R.id.groupItem1).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startIntentanimation(activity, LoginUpdateNewActivity.class);
//                popupWindow.dismiss();
//            }
//        });
//        /*
//        * 修改支付密码
//        * */
//        view.findViewById(R.id.groupItem2).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startIntentanimation(activity, LoginUpdateZfuActivity.class);
//                popupWindow.dismiss();
//            }
//        });
//        /*
//        * 退出
//        * */
//        view.findViewById(R.id.groupItem3).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                closeLogIN(activity);
//                popupWindow.dismiss();
//            }
//        });
//        /*
//        * 添加银行卡
//        * */
//        view.findViewById(R.id.groupItem4).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startIntentanimation(activity, LoginBankActivity.class);
//                popupWindow.dismiss();
//
//            }
//        });
//
//    }


    /*
     * 退出登录
     * */
    public static void closeLogIN(Activity context) {
        BcUtils.deleteAll();
        startIntent(context, UserLogInActivity.class, true);
        context.setResult(Activity.RESULT_OK);
        context.finish();
    }


    /*
     * ==================================================================================================================================
     * */
//时长格式化 X小时X分钟X秒
    public static String getDuration(int duration) {
        String result = "";
        try {
            int a = duration % 60;//秒
            int b = duration / 60;//分
            if (b < 1) {//小于1分钟
                result = a + "秒";
            } else if (b < 60) {//小于60分钟
                if (a == 0) {
                    result = b + "分钟";
                } else {
                    result = b + "分钟" + a + "秒";
                }
            } else {//大于60分钟显示小时
                int c = b % 60;
                int d = b / 60;
                if (c == 0) {
                    if (a == 0) {
                        result = d + "小时";
                    } else {
                        result = d + "小时" + a + "秒";
                    }
                } else {
                    if (a == 0) {
                        result = d + "小时" + c + "分钟";
                    } else {
                        result = d + "小时" + c + "分钟" + a + "秒";
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static String getUser() {
//        Log.i("用户信息:","uid="+BcUtils.getUid()+"&authcode="+BcUtils.getAuthcode()+"&username="+BcUtils.getUserName()+"&res="+BcUtils.getRealusername());
        return "?uid=" + BcUtils.getUid();
    }


    //底部跳转
    /*
     * 务必要有inclod_bottom.xml布局
     * */
//    public static void startIntentBottm(final Activity activity, final int num) {
//        /*
//          0.随意可跳转
//        * 1.首页
//        * 2.ep相册
//        * 3.rp相册
//        * 4.会员网络
//        * */
//        ImageView img;
//        TextView textView;
//        switch (num){
//            case 1:
//                img = (ImageView) activity.findViewById(R.id.bottom_img_s1);
//                img.setImageResource(R.mipmap.c1);
//                textView = (TextView) activity.findViewById(R.id.bottom_txt_s1);
//                textView.setTextColor(activity.getResources().getColor(R.color.yqiannew));
//                break;
//            case 2:
//                img = (ImageView) activity.findViewById(R.id.bottom_img_s2);
//                img.setImageResource(R.mipmap.c2);
//                textView = (TextView) activity.findViewById(R.id.bottom_txt_s2);
//                textView.setTextColor(activity.getResources().getColor(R.color.yqiannew));
//                break;
//            case 3:
//                img = (ImageView) activity.findViewById(R.id.bottom_img_s3);
//                img.setImageResource(R.mipmap.c3);
//                textView = (TextView) activity.findViewById(R.id.bottom_txt_s3);
//                textView.setTextColor(activity.getResources().getColor(R.color.yqiannew));
//                break;
//            case 4:
//                img = (ImageView) activity.findViewById(R.id.bottom_img_jiaoyi);
//                img.setImageResource(R.mipmap.jiaoyiok);
//                textView = (TextView) activity.findViewById(R.id.bottom_txt_jiaoyi);
//                textView.setTextColor(activity.getResources().getColor(R.color.yqiannew));
//                break;
//        }
//        activity.findViewById(R.id.bottom_btn_main).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if(num!=1) {
//                    intent = new Intent(activity, MainActivity.class);
//                    activity.startActivity(intent);
//                    activity.overridePendingTransition(0,0);
//                }
//            }
//        });
////
//        activity.findViewById(R.id.bottom_btn_ep).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if(num!=2) {
//                    intent = new Intent(activity, BillActivity.class);
//                    activity.startActivity(intent);
//                    activity.overridePendingTransition(0,0);
//                }
//            }
//        });
//        activity.findViewById(R.id.bottom_btn_network).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if(num!=3) {
//                    intent = new Intent(activity, MyInfoActivity.class);
//                    activity.startActivity(intent);
//                    activity.overridePendingTransition(0,0);
//                }
//            }
//        });
//        activity.findViewById(R.id.bottom_btn_jiaoyi).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if(num!=4) {
//                    intent = new Intent(activity, JiaoyiActivity.class);
//                    activity.startActivity(intent);
//                    activity.overridePendingTransition(0,0);
//                }
//            }
//        });
//
//    }


    /*
     * 强制关闭软键盘
     * */
    public static void showOrHide(Context context, Activity activity) {
        ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
                .hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
    }

    // 判断手机号码是否规则
    public static boolean isPhoneNumber(String input) {
        String regex = "(1[0-9][0-9]|15[0-9]|18[0-9])\\d{8}";
        Pattern p = Pattern.compile(regex);
        return p.matches(regex, input);
    }

    /**
     * 把json 转换为ArrayList 形式
     *
     * @return
     */
    public static List<Map<String, Object>> getList(String jsonString) {

        List<Map<String, Object>> list = null;
        try {
            JSONArray jsonArray = new JSONArray(jsonString);
            JSONObject jsonObject;
            list = new ArrayList<Map<String, Object>>();
            for (int i = 0; i < jsonArray.length(); i++) {
                jsonObject = jsonArray.getJSONObject(i);
                list.add(getMap(jsonObject.toString()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }


    /*
     * 复制到粘贴板
     * */
    public static void copy(String info) {
        ClipboardManager cm = (ClipboardManager) App.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
        // 将文本内容放到系统剪贴板里。
        cm.setText(info);
    }

    /**
     * 将json 数组转换为Map 对象
     *
     * @param jsonString
     * @return
     */
    public static Map<String, Object> getMap(String jsonString) {
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(jsonString);
            Iterator<String> keyIter = jsonObject.keys();
            String key;
            Object value;
            Map<String, Object> valueMap = new HashMap<String, Object>();
            while (keyIter.hasNext()) {
                key = (String) keyIter.next();
                value = jsonObject.get(key);
                valueMap.put(key, value);
            }
            return valueMap;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }


    //判断网络是否可用 有网络返回true
    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (cm == null) {
        } else {

            NetworkInfo[] info = cm.getAllNetworkInfo();
            if (info != null) {
                for (int i = 0; i < info.length; i++) {
                    if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                        return true;
                    }
                }
            }
        }
        return false;
    }


    public static String randomInt() {
        return String.valueOf(new Random().nextInt(999 * 999) + 10);
    }

    /*
     * 加载圆角图片
     * */
//    public static void loadImgYuan(Context context,String url,ImageView imageView){
//        Glide.with(context)
//                .load(url)
//                .transform(new CenterCrop(context), new GlideRoundTransform(context,30))
//                .into(imageView);
//    }
    /*
     * 加载基础 图片
     * */
    public static void loadImg(String url, ImageView img) {
        try {
            Glide.with(App.getContext()).load(url)
                    .dontAnimate()
                    .skipMemoryCache(false)
                    .into(img);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 检测是否安装支付宝
     *
     * @param context
     * @return
     */
    public static boolean isAliPayInstalled(Context context) {
        Uri uri = Uri.parse("alipays://platformapi/startApp");
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        ComponentName componentName = intent.resolveActivity(context.getPackageManager());
        return componentName != null;
    }

    /**
     * 检测是否安装微信
     *
     * @param context
     * @return
     */
    public static boolean isWeixinAvilible(Context context) {
        final PackageManager packageManager = context.getPackageManager();// 获取packagemanager
        List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
        if (pinfo != null) {
            for (int i = 0; i < pinfo.size(); i++) {
                String pn = pinfo.get(i).packageName;
                if (pn.equals("com.tencent.mm")) {
                    return true;
                }
            }
        }
        return false;
    }


    public static void recLoad(Activity activity, PullToRefreshRecyclerView refreshRecyclerView, PullToRefreshListener pullToRefreshListener) {
        refreshRecyclerView.setNestedScrollingEnabled(false);
        View emptyView = View.inflate(activity, R.layout.layout_empty_view, null);
        emptyView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        refreshRecyclerView.setEmptyView(emptyView);
        LinearLayoutManager layoutManager = new LinearLayoutManager(activity);

        refreshRecyclerView.setLayoutManager(layoutManager);
        refreshRecyclerView.setHasFixedSize(true);
        //是否开启下拉刷新功能
        refreshRecyclerView.setPullRefreshEnabled(true);
        //是否开启上拉加载功能
        refreshRecyclerView.setLoadingMoreEnabled(true);
        //设置是否显示上次刷新的时间
        refreshRecyclerView.displayLastRefreshTime(true);
        //设置刷新回调
        refreshRecyclerView.setPullToRefreshListener(pullToRefreshListener);
    }

    /*
     * 如果等于1那就是横向
     * */
    @SuppressLint("WrongConstant")
    public static void recLoad(Activity activity, RecyclerView refreshRecyclerView, int num) {
        refreshRecyclerView.setNestedScrollingEnabled(false);
        LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
        if (num == 1) {
            layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        } else if (num == 2) {
            layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        }
        refreshRecyclerView.setLayoutManager(layoutManager);
        refreshRecyclerView.setHasFixedSize(true);
    }


    /*
     * 强制关闭软键盘
     * */
    public static void closeShuru(Activity context, View v) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }

    /*
     * 将时间戳转换为时间
     */
    public static String stampToDate(String s) {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long lt = (Long.valueOf(s) * 1000);
        Date date = new Date(lt);
        res = simpleDateFormat.format(date);
        return res;
    }


    public static void initMapLocation(LocationClient mLocationClient, BDAbstractLocationListener locationListener) {
        /**
         * 初始化地图定位
         */
        mLocationClient = new LocationClient(App.getContext());
        LocationClientOption option = new LocationClientOption();
        option.setIsNeedAddress(true);// //可选，默认false，设置是否需要POI结果，可以在BDLocation.getPoiList里得到
        option.setOpenGps(true);// 打开gps
        option.setCoorType("bd09ll");//可选，默认gcj02，设置返回的定位结果坐标系
        option.setScanSpan(0);//可选，默认0，即仅定位一次，设置发起定位请求的间隔需要大于等于1000ms才是有效的
        option.setIsNeedAddress(true);//可选，设置是否需要地址信息，默认不需要
        option.setLocationNotify(false);//可选，默认false，设置是否当GPS有效时按照1S/1次频率输出GPS结果
        option.setIsNeedLocationDescribe(true);//可选，默认false，设置是否需要位置语义化结果，可以在BDLocation
        // .getLocationDescribe里得到，结果类似于“在北京天安门附近”
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        option.setIgnoreKillProcess(false); //可选，默认true，定位SDK内部是一个SERVICE，并放到了独立进程，设置是否在stop的时候杀死这个进程，默认不杀死
        option.SetIgnoreCacheException(false);//可选，默认false，设置是否收集CRASH信息，默认收集
        option.setEnableSimulateGps(false);//可选，默认false，设置是否需要过滤GPS仿真结果，默认需要
        option.setAddrType("all");
        option.setProdName("ipark");
        mLocationClient.registerLocationListener(locationListener);
        mLocationClient.setLocOption(option);
        mLocationClient.start();
    }


}
